package com.zcmyth;

/*
http://download.oracle.com/javase/7/docs/api/java/util/Formatter.html#syntax
*/
public class StringFormat
{
	public static void main(String[] args) {
		RGB(new int[]{1,-2,3});
	}
	
	/*
	Format an RGB value (three 1-byte numbers) as a 6-digit hexadecimal string.
	*/
	static void RGB(int [] a)
	{
		for(int i : a)
			System.out.println(String.format("|%+04d|",i));
	}
	
	/*
	Print out the grade-school multiplication table up to 12x12
	*/
	public static void table(int size)
	{
		for(int i=0;i<size;i++)
		{
			int x = i+1;
			int y = 0;
			for(int j=0;j<size;j++)
			{
				y = x+y;
				System.out.print(String.format ( "%4d",y));
			}
			System.out.println();
		}
	}
}